package com.study.experiment08.clazz;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Test {
    public static void main(String[] args) {
        Course course = null;
        ApplicationContext ctx =
                new ClassPathXmlApplicationContext("/applicationContext.xml");
        System.out.println("====第 1 个 Bean,通过无参构造方法实例化====");
        course = (Course) ctx.getBean("course1");
        System.out.println(course);
        System.out.println("====第 2 个 Bean,通过构造方法实例化====");
        course = (Course) ctx.getBean("course2");
        System.out.println(course);
        System.out.println("====第 3 个 Bean,通过静态工厂方法实例化 ====");
        course = (Course) ctx.getBean("course3");
        System.out.println(course);
        System.out.println("====第 4 个 Bean,通过非静态工厂方法实例化====");
        course = (Course) ctx.getBean("course4");
        System.out.println(course);
        System.out.println("====第 5 个 Bean,通过非静态工厂方法实例化 ====");
        Human human = null;
        human = (Human) ctx.getBean("chinese");
        human.speak();
        System.out.println("====第 6 个 Bean,通过非静态工厂方法实例化 ====");
        human = (Chinese) ctx.getBean("chinese2");
        human.speak();
        System.out.println("=====第 7 个 Bean,为 Map 类和 List 属性注入 =====");
        System.out.println("=================Map 属性=============");
        Student student1 = (Student) ctx.getBean("student");
        System.out.println(student1);
        System.out.println("=================List 属性=============");
        System.out.println(student1.toString2());
    }

}
